Page({
  data: {
    statusBarHeight: 0
  },

  onLoad() {
    const windowInfo = wx.getWindowInfo();
    this.setData({
      statusBarHeight: windowInfo.statusBarHeight
    });
  },

  onShow() {
    // 🔔 自动初始化通知组件
    const app = getApp();
    app.autoInitNotification();
  },

  // 返回
  goBack() {
    wx.navigateBack();
  },

  // 注销账号
  cancelAccount() {
    wx.showModal({
      title: '确认注销',
      content: '注销后账号将无法恢复，确定要注销吗？',
      confirmText: '确认注销',
      confirmColor: '#D84545',
      cancelText: '取消',
      success: (res) => {
        if (res.confirm) {
          wx.showLoading({
            title: '注销中...',
            mask: true
          });
          
          // 模拟注销请求
          setTimeout(() => {
            wx.hideLoading();
            wx.showToast({
              title: '注销成功',
              icon: 'success',
              duration: 2000,
              success: () => {
                setTimeout(() => {
                  wx.reLaunch({
                    url: '/pages/login/index'
                  });
                }, 2000);
              }
            });
          }, 1500);
        }
      }
    });
  }
});

